/* @(#)Bbs.java    V1.0
 *
 * Project: APEP
 *
 * Modify Information:
 * =============================================================================
 *   Author       Date       Description
 *   ------------ ---------- ---------------------------------------------------
 *   wangp    {CREATE_TIME} First release
 *
 * Copyright Notice:
 * =============================================================================
 *    Copyright (c) 2001-2007 Auto-Parts E-Procurement Co., Ltd.
 *        No.251-1 Wuning Road, Shanghai, 200063, China All rights reserved.
 *
 *    This software is the confidential and proprietary information of
 *        Auto-Parts E-Procurement Co., Ltd. ("Confidential Information").
 *        You shall not disclose such Confidential Information and shall use it
 *        only in accordance with the terms of the license agreement you entered
 *        into with APEP.
 *
 * Warning:
 * =============================================================================
 * 
 * 
 */
package system.base;

import framework.core.Conditions;
import framework.core.SearchEvent;
import framework.core.Value;

/*
	Author    :wangp
	CreateTime:{CREATE_TIME}
 */
public class BbsSearchEvent extends SearchEvent
{
	private static final long serialVersionUID = 1L;

	private int m_ID = Value.NULL_INT ; // all

	private String m_SUBJECT = "" ; // all

	private String m_CONTENT = "" ; // all

	private String m_CREATE_USER_ID = "" ; // all

	private String m_CREATE_TIME = "" ; // all

	private String m_CREATE_USER = "" ; // all

	private int m_REL_ID = Value.NULL_INT ; // all

	private int m_REPLY_NUM = Value.NULL_INT ; // all

	private int m_BROWER_NUM = Value.NULL_INT ; // all

	private int m_LAST_RE_TIME = Value.NULL_INT ; // all

	private String m_LAST_RE_USER = "" ; // all

	private String m_RESERVE1 = "" ; // all

	private String m_RESERVE2 = "" ; // all

	private String m_RESERVE3 = "" ; // all

	private String m_START_CREATE_TIME = "";

	private String m_END_CREATE_TIME = "";

	private String m_REL_USER_ID = "";

	private int m_HAS_REPLIES = Value.NULL_INT;


	public BbsSearchEvent()
	{
		super();

		setOrderField(Bbs.ID);

	}

	public String getStartCreateTime() {
		return m_START_CREATE_TIME;
	}
	public void setStartCreateTime(String v) {
		m_START_CREATE_TIME = v;
	}

	public String getEndCreateTime() {
		return m_END_CREATE_TIME;
	}
	public void setEndCreateTime(String v) {
		m_END_CREATE_TIME = v;
	}

	public String getRelUserId() {
		return m_REL_USER_ID;
	}

	public void setRelUserId(String v) {
		m_REL_USER_ID = v;
	}

	public int getHasReplies() {
		return m_HAS_REPLIES;
	}

	public void setHasReplies(int v) {
		m_HAS_REPLIES = v;
	}


	public int getId()
	{
		return m_ID ;
	}
	public void setId(int v)
	{
		m_ID = v;
	}

	public String getSubject()
	{
		return m_SUBJECT ;
	}
	public void setSubject(String v)
	{
		m_SUBJECT = v;
	}

	public String getContent()
	{
		return m_CONTENT ;
	}
	public void setContent(String v)
	{
		m_CONTENT = v;
	}

	public String getCreateUserId()
	{
		return m_CREATE_USER_ID ;
	}
	public void setCreateUserId(String v)
	{
		m_CREATE_USER_ID = v;
	}

	public String getCreateTime()
	{
		return m_CREATE_TIME ;
	}
	public void setCreateTime(String v)
	{
		m_CREATE_TIME = v;
	}

	public String getCreateUser()
	{
		return m_CREATE_USER ;
	}
	public void setCreateUser(String v)
	{
		m_CREATE_USER = v;
	}

	public int getRelId()
	{
		return m_REL_ID ;
	}
	public void setRelId(int v)
	{
		m_REL_ID = v;
	}

	public int getReplyNum()
	{
		return m_REPLY_NUM ;
	}
	public void setReplyNum(int v)
	{
		m_REPLY_NUM = v;
	}

	public int getBrowerNum()
	{
		return m_BROWER_NUM ;
	}
	public void setBrowerNum(int v)
	{
		m_BROWER_NUM = v;
	}

	public int getLastReTime()
	{
		return m_LAST_RE_TIME ;
	}
	public void setLastReTime(int v)
	{
		m_LAST_RE_TIME = v;
	}

	public String getLastReUser()
	{
		return m_LAST_RE_USER ;
	}
	public void setLastReUser(String v)
	{
		m_LAST_RE_USER = v;
	}

	public String getReserve1()
	{
		return m_RESERVE1 ;
	}
	public void setReserve1(String v)
	{
		m_RESERVE1 = v;
	}

	public String getReserve2()
	{
		return m_RESERVE2 ;
	}
	public void setReserve2(String v)
	{
		m_RESERVE2 = v;
	}

	public String getReserve3()
	{
		return m_RESERVE3 ;
	}
	public void setReserve3(String v)
	{
		m_RESERVE3 = v;
	}




	public String viewId() throws Exception
	{
		return Value.view(getId());
	}

	public String viewSubject() throws Exception
	{
		return Value.view(getSubject());
	}

	public String viewContent() throws Exception
	{
		return Value.view(getContent());
	}

	public String viewCreateUserId() throws Exception
	{
		return Value.view(getCreateUserId());
	}

	public String viewCreateTime() throws Exception
	{
		return Value.view(getCreateTime());
	}

	public String viewCreateUser() throws Exception
	{
		return Value.view(getCreateUser());
	}

	public String viewRelId() throws Exception
	{
		return Value.view(getRelId());
	}

	public String viewReplyNum() throws Exception
	{
		return Value.view(getReplyNum());
	}

	public String viewBrowerNum() throws Exception
	{
		return Value.view(getBrowerNum());
	}

	public String viewLastReTime() throws Exception
	{
		return Value.view(getLastReTime());
	}

	public String viewLastReUser() throws Exception
	{
		return Value.view(getLastReUser());
	}

	public String viewReserve1() throws Exception
	{
		return Value.view(getReserve1());
	}

	public String viewReserve2() throws Exception
	{
		return Value.view(getReserve2());
	}

	public String viewReserve3() throws Exception
	{
		return Value.view(getReserve3());
	}

	public String viewStartCreateTime() throws Exception {
		return Value.view(getStartCreateTime());
	}

	public String viewEndCreateTime() throws Exception {
		return Value.view(getEndCreateTime());
	}


	public Conditions toConditions() throws Exception
	{
		Conditions c = super.toConditions();

		c.add(getCondition(Bbs.ID,getId()));

		c.add(getCondition(Bbs.SUBJECT,getSubject()));

		c.add(getCondition(Bbs.CONTENT,getContent()));

		c.add(getCondition(Bbs.CREATE_USER_ID,getCreateUserId()));

		c.add(getCondition(Bbs.CREATE_TIME,getCreateTime()));

		c.add(getCondition(Bbs.CREATE_USER,getCreateUser()));

		c.add(getCondition(Bbs.REL_ID,getRelId()));

		c.add(getCondition(Bbs.REPLY_NUM,getReplyNum()));

		c.add(getCondition(Bbs.BROWER_NUM,getBrowerNum()));

		c.add(getCondition(Bbs.LAST_RE_TIME,getLastReTime()));

		c.add(getCondition(Bbs.LAST_RE_USER,getLastReUser()));

		c.add(getCondition(Bbs.RESERVE1,getReserve1()));

		c.add(getCondition(Bbs.RESERVE2,getReserve2()));

		c.add(getCondition(Bbs.RESERVE3,getReserve3()));


		if(getStartCreateTime() != null && getStartCreateTime().length() > 0) {
			c.add(Bbs.CREATE_TIME, Conditions.GREATER_EQUAL, getStartCreateTime());
		}

		if(getEndCreateTime() != null && getEndCreateTime().length() > 0) {
			c.add(Bbs.CREATE_TIME, Conditions.LESS_EQUAL, getEndCreateTime() + " 24:00:00");
		}

		if(getRelUserId() != null && getRelUserId().length() > 0) {
			c.add("(CREATE_USER_ID = ? or exists (select id from t_bbs a where a.rel_id = t_bbs.id and a.create_user_id = ? ))", Conditions.CUSTOM, new String[]{getRelUserId(), getRelUserId()});
		}

		if(getHasReplies() > 0) {
			c.add(Bbs.REPLY_NUM, Conditions.GREATER_THAN, 0);
		}


		return c ;
	}

	//add by wangp start

	//add by wangp end
}
